package cli
import (
	"github.com/micro/go-micro/cmd"
	product "git.oschina.net/fanbuchi/xgggh/product/proto/product"
	"github.com/micro/go-micro/client"
	"golang.org/x/net/context"
)
// Query 对外提供商品查询服务
// 是否需要鉴权 否
func Query(params *product.QueryReq)(*product.QueryRsp,error) {
	cmd.Init()
	_client:=client.DefaultClient
	cl := product.NewProductsClient("com.xgggh.srv.product", _client)
	ctx:=context.Background()
	rsp, err := cl.Query(ctx, params)
	if err != nil {
		return nil,err
	}
	return rsp,nil
}

//查询商品列表数据
func QueryList(params *product.QueryListReq)(*product.QueryListRsp,error) {
	cmd.Init()
	_client:=client.DefaultClient
	cl := product.NewProductsClient("com.xgggh.srv.product", _client)
	ctx:=context.Background()
	rsp, err := cl.QueryList(ctx, params)
	if err != nil {
		return nil,err
	}
	return rsp,nil
}

//查询列表中的商品
func Search(params *product.SearchReq)(*product.SearchRsp,error) {
	cmd.Init()
	_client:=client.DefaultClient
	cl := product.NewProductsClient("com.xgggh.srv.product", _client)
	ctx:=context.Background()
	rsp, err := cl.Search(ctx, params)
	if err != nil {
		return nil,err
	}
	return rsp,nil
}
